package com.nyist.myticket.web.controller;


import com.nyist.myticket.biz.entity.CityArea;
import com.nyist.myticket.biz.service.CityAreaService;
import com.nyist.myticket.core.base.BaseController;
import com.nyist.myticket.core.base.BaseEntity;
import com.nyist.myticket.core.common.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author yangxiaogen
 * @since 2021-01-05
 */
@RestController
@RequestMapping("/cityArea")
public class CityAreaController extends BaseController {

    @Autowired
    private CityAreaService cityAreaService;

    @Override
    public ResponseResult checkHandle(ResponseResult responseResult, BaseEntity baseEntity) {
        return null;
    }

    @PostMapping("/queryAreaByCode")
    public CityArea queryAreaByCode(@RequestBody CityArea cityArea) {

        return cityAreaService.queryByAreaCode(cityArea.getAreaCode());
    }

    @PostMapping("/queryAreaByName")
    public CityArea queryAreaByName(@RequestBody CityArea cityArea) {

        return cityAreaService.queryByAreaName(cityArea.getAreaName());
    }

    @PostMapping("/queryAreaByLevel")
    public List<CityArea> queryAreaByLevel(@RequestBody CityArea cityArea) {

        return cityAreaService.queryByAreaLevel(cityArea.getAreaLevel());
    }

    @PostMapping("/queryAreaByLevelAndParent")
    public List<CityArea> queryAreaByLevelAndParent(@RequestBody CityArea cityArea) {

        return cityAreaService.queryByAreaLevelAndParentAreaCode(cityArea.getAreaLevel(), cityArea.getParentAreaCode());
    }


}

